package com.itheima.mapper;

import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {
    List<Clazz> page(ClazzQueryParam clazzQueryParam);

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    @Insert("INSERT INTO clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time)\n" +
            "    VALUES(#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})\n")
    void save(Clazz clazz);

    @Select("select * from clazz where id=#{id}")
    Clazz selectById(Integer id);

    @Update("update clazz set name=#{name}, room=#{room}, begin_date=#{beginDate}, end_date=#{endDate}, master_id=#{masterId}, subject=#{subject}, create_time=#{createTime}, update_time=#{updateTime} where id=#{id}")
    void updateById(Clazz clazz);

    @Select("select * from clazz")
    List<Clazz> listAll();
}
